﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SongSharp.Domain.Suggesting;
using SongSharp.Logging;

namespace SongSharp.Domain.Suggesting.VaryVogueValue
{
    public class VitalGenerator : ChanceGenerator
    {
        public static readonly double[] PlaySkipRatioBounds = new double[] { 0.05, 0.2, 1.0, 5.0, 10.0, 30.0 };

        static VitalGenerator()
        {
            RulesTable.Add("vital_played_skipped_ratio", new RuleSet(PlaySkipRatioBounds, 0.8));
        }

        public override ChanceValue Generate(Objects.Track track)
        {
            double ratio = (track.Statistic.PlayedExplicitCount + 1.0) / (track.Statistic.SkippedCount + 1.0);
            ChanceValue chance = RulesManager.CreateInterpretation("vital_played_skipped_ratio", ratio);
            chance.ValueType = ChanceValue.VVVType.Vital_Played_Skipped_Ratio;
            
            // Logging/Debugging - Start
            Logger.Log("   Vital, played-skipped-ratio: " + (track.Statistic.PlayedExplicitCount + 1.0)
                + "/" + (track.Statistic.SkippedCount + 1.0) + ", x = " + Math.Round(chance.Value, 4) + 
                ", DeB = " + chance.DegreeOfBelief);
            // Logging/Debugging - End

            return chance;
        }
    }
}
